<?php


/**
 * Base class that represents a query for the 'lp_vv_UmowyStanowiska' table.
 *
 *
 *
 * @method LpUmowyStanowiskaQuery orderById($order = Criteria::ASC) Order by the lp_UmowyStanowiskaId column
 * @method LpUmowyStanowiskaQuery orderByStartDate($order = Criteria::ASC) Order by the DataOd column
 * @method LpUmowyStanowiskaQuery orderByEndDate($order = Criteria::ASC) Order by the DataDo column
 * @method LpUmowyStanowiskaQuery orderByPositionId($order = Criteria::ASC) Order by the Stanowisko column
 * @method LpUmowyStanowiskaQuery orderByLogoId($order = Criteria::ASC) Order by the LpLogo column
 *
 * @method LpUmowyStanowiskaQuery groupById() Group by the lp_UmowyStanowiskaId column
 * @method LpUmowyStanowiskaQuery groupByStartDate() Group by the DataOd column
 * @method LpUmowyStanowiskaQuery groupByEndDate() Group by the DataDo column
 * @method LpUmowyStanowiskaQuery groupByPositionId() Group by the Stanowisko column
 * @method LpUmowyStanowiskaQuery groupByLogoId() Group by the LpLogo column
 *
 * @method LpUmowyStanowiskaQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
 * @method LpUmowyStanowiskaQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
 * @method LpUmowyStanowiskaQuery innerJoin($relation) Adds a INNER JOIN clause to the query
 *
 * @method LpUmowyStanowiskaQuery leftJoinPositions($relationAlias = null) Adds a LEFT JOIN clause to the query using the Positions relation
 * @method LpUmowyStanowiskaQuery rightJoinPositions($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Positions relation
 * @method LpUmowyStanowiskaQuery innerJoinPositions($relationAlias = null) Adds a INNER JOIN clause to the query using the Positions relation
 *
 * @method LpUmowyStanowiska findOne(PropelPDO $con = null) Return the first LpUmowyStanowiska matching the query
 * @method LpUmowyStanowiska findOneOrCreate(PropelPDO $con = null) Return the first LpUmowyStanowiska matching the query, or a new LpUmowyStanowiska object populated from the query conditions when no match is found
 *
 * @method LpUmowyStanowiska findOneById(string $lp_UmowyStanowiskaId) Return the first LpUmowyStanowiska filtered by the lp_UmowyStanowiskaId column
 * @method LpUmowyStanowiska findOneByStartDate(string $DataOd) Return the first LpUmowyStanowiska filtered by the DataOd column
 * @method LpUmowyStanowiska findOneByEndDate(string $DataDo) Return the first LpUmowyStanowiska filtered by the DataDo column
 * @method LpUmowyStanowiska findOneByPositionId(string $Stanowisko) Return the first LpUmowyStanowiska filtered by the Stanowisko column
 * @method LpUmowyStanowiska findOneByLogoId(string $LpLogo) Return the first LpUmowyStanowiska filtered by the LpLogo column
 *
 * @method array findById(string $lp_UmowyStanowiskaId) Return LpUmowyStanowiska objects filtered by the lp_UmowyStanowiskaId column
 * @method array findByStartDate(string $DataOd) Return LpUmowyStanowiska objects filtered by the DataOd column
 * @method array findByEndDate(string $DataDo) Return LpUmowyStanowiska objects filtered by the DataDo column
 * @method array findByPositionId(string $Stanowisko) Return LpUmowyStanowiska objects filtered by the Stanowisko column
 * @method array findByLogoId(string $LpLogo) Return LpUmowyStanowiska objects filtered by the LpLogo column
 *
 * @package    propel.generator.lp.om
 */
abstract class LpBaseUmowyStanowiskaQuery extends ModelCriteria
{
    /**
     * Initializes internal state of LpBaseUmowyStanowiskaQuery object.
     *
     * @param     string $dbName The dabase name
     * @param     string $modelName The phpName of a model, e.g. 'Book'
     * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
     */
    public function __construct($dbName = 'vw_lp', $modelName = 'LpUmowyStanowiska', $modelAlias = null)
    {
        parent::__construct($dbName, $modelName, $modelAlias);
    }

    /**
     * Returns a new LpUmowyStanowiskaQuery object.
     *
     * @param     string $modelAlias The alias of a model in the query
     * @param     LpUmowyStanowiskaQuery|Criteria $criteria Optional Criteria to build the query from
     *
     * @return LpUmowyStanowiskaQuery
     */
    public static function create($modelAlias = null, $criteria = null)
    {
        if ($criteria instanceof LpUmowyStanowiskaQuery) {
            return $criteria;
        }
        $query = new LpUmowyStanowiskaQuery();
        if (null !== $modelAlias) {
            $query->setModelAlias($modelAlias);
        }
        if ($criteria instanceof Criteria) {
            $query->mergeWith($criteria);
        }

        return $query;
    }

    /**
     * Find object by primary key.
     * Propel uses the instance pool to skip the database if the object exists.
     * Go fast if the query is untouched.
     *
     * <code>
     * $obj  = $c->findPk(12, $con);
     * </code>
     *
     * @param mixed $key Primary key to use for the query
     * @param     PropelPDO $con an optional connection object
     *
     * @return   LpUmowyStanowiska|LpUmowyStanowiska[]|mixed the result, formatted by the current formatter
     */
    public function findPk($key, $con = null)
    {
        if ($key === null) {
            return null;
        }
        if ((null !== ($obj = LpUmowyStanowiskaPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
            // the object is alredy in the instance pool
            return $obj;
        }
        if ($con === null) {
            $con = Propel::getConnection(LpUmowyStanowiskaPeer::DATABASE_NAME, Propel::CONNECTION_READ);
        }
        $this->basePreSelect($con);
        if ($this->formatter || $this->modelAlias || $this->with || $this->select
         || $this->selectColumns || $this->asColumns || $this->selectModifiers
         || $this->map || $this->having || $this->joins) {
            return $this->findPkComplex($key, $con);
        } else {
            return $this->findPkSimple($key, $con);
        }
    }

    /**
     * Find object by primary key using raw SQL to go fast.
     * Bypass doSelect() and the object formatter by using generated code.
     *
     * @param     mixed $key Primary key to use for the query
     * @param     PropelPDO $con A connection object
     *
     * @return   LpUmowyStanowiska A model object, or null if the key is not found
     * @throws   PropelException
     */
    protected function findPkSimple($key, $con)
    {
        $sql = 'SELECT LP_UMOWYSTANOWISKAID, DATAOD, DATADO, STANOWISKO, LPLOGO FROM lp_vv_UmowyStanowiska WHERE LP_UMOWYSTANOWISKAID = :p0';
        try {
            $stmt = $con->prepare($sql);
            $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
            $stmt->execute();
        } catch (Exception $e) {
            Propel::log($e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
        }
        $obj = null;
        if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
            $obj = new LpUmowyStanowiska();
            $obj->hydrate($row);
            LpUmowyStanowiskaPeer::addInstanceToPool($obj, (string) $key);
        }
        $stmt->closeCursor();

        return $obj;
    }

    /**
     * Find object by primary key.
     *
     * @param     mixed $key Primary key to use for the query
     * @param     PropelPDO $con A connection object
     *
     * @return LpUmowyStanowiska|LpUmowyStanowiska[]|mixed the result, formatted by the current formatter
     */
    protected function findPkComplex($key, $con)
    {
        // As the query uses a PK condition, no limit(1) is necessary.
        $criteria = $this->isKeepQuery() ? clone $this : $this;
        $stmt = $criteria
            ->filterByPrimaryKey($key)
            ->doSelect($con);

        return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
    }

    /**
     * Find objects by primary key
     * <code>
     * $objs = $c->findPks(array(12, 56, 832), $con);
     * </code>
     * @param     array $keys Primary keys to use for the query
     * @param     PropelPDO $con an optional connection object
     *
     * @return PropelObjectCollection|LpUmowyStanowiska[]|mixed the list of results, formatted by the current formatter
     */
    public function findPks($keys, $con = null)
    {
        if ($con === null) {
            $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
        }
        $this->basePreSelect($con);
        $criteria = $this->isKeepQuery() ? clone $this : $this;
        $stmt = $criteria
            ->filterByPrimaryKeys($keys)
            ->doSelect($con);

        return $criteria->getFormatter()->init($criteria)->format($stmt);
    }

    /**
     * Filter the query by primary key
     *
     * @param     mixed $key Primary key to use for the query
     *
     * @return LpUmowyStanowiskaQuery The current query, for fluid interface
     */
    public function filterByPrimaryKey($key)
    {

        return $this->addUsingAlias(LpUmowyStanowiskaPeer::LP_UMOWYSTANOWISKAID, $key, Criteria::EQUAL);
    }

    /**
     * Filter the query by a list of primary keys
     *
     * @param     array $keys The list of primary key to use for the query
     *
     * @return LpUmowyStanowiskaQuery The current query, for fluid interface
     */
    public function filterByPrimaryKeys($keys)
    {

        return $this->addUsingAlias(LpUmowyStanowiskaPeer::LP_UMOWYSTANOWISKAID, $keys, Criteria::IN);
    }

    /**
     * Filter the query on the lp_UmowyStanowiskaId column
     *
     * Example usage:
     * <code>
     * $query->filterById(1234); // WHERE lp_UmowyStanowiskaId = 1234
     * $query->filterById(array(12, 34)); // WHERE lp_UmowyStanowiskaId IN (12, 34)
     * $query->filterById(array('min' => 12)); // WHERE lp_UmowyStanowiskaId > 12
     * </code>
     *
     * @param     mixed $id The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return LpUmowyStanowiskaQuery The current query, for fluid interface
     */
    public function filterById($id = null, $comparison = null)
    {
        if (is_array($id) && null === $comparison) {
            $comparison = Criteria::IN;
        }

        return $this->addUsingAlias(LpUmowyStanowiskaPeer::LP_UMOWYSTANOWISKAID, $id, $comparison);
    }

    /**
     * Filter the query on the DataOd column
     *
     * Example usage:
     * <code>
     * $query->filterByStartDate('2011-03-14'); // WHERE DataOd = '2011-03-14'
     * $query->filterByStartDate('now'); // WHERE DataOd = '2011-03-14'
     * $query->filterByStartDate(array('max' => 'yesterday')); // WHERE DataOd > '2011-03-13'
     * </code>
     *
     * @param     mixed $startDate The value to use as filter.
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
     *              Empty strings are treated as NULL.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return LpUmowyStanowiskaQuery The current query, for fluid interface
     */
    public function filterByStartDate($startDate = null, $comparison = null)
    {
        if (is_array($startDate)) {
            $useMinMax = false;
            if (isset($startDate['min'])) {
                $this->addUsingAlias(LpUmowyStanowiskaPeer::DATAOD, $startDate['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($startDate['max'])) {
                $this->addUsingAlias(LpUmowyStanowiskaPeer::DATAOD, $startDate['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(LpUmowyStanowiskaPeer::DATAOD, $startDate, $comparison);
    }

    /**
     * Filter the query on the DataDo column
     *
     * Example usage:
     * <code>
     * $query->filterByEndDate('2011-03-14'); // WHERE DataDo = '2011-03-14'
     * $query->filterByEndDate('now'); // WHERE DataDo = '2011-03-14'
     * $query->filterByEndDate(array('max' => 'yesterday')); // WHERE DataDo > '2011-03-13'
     * </code>
     *
     * @param     mixed $endDate The value to use as filter.
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
     *              Empty strings are treated as NULL.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return LpUmowyStanowiskaQuery The current query, for fluid interface
     */
    public function filterByEndDate($endDate = null, $comparison = null)
    {
        if (is_array($endDate)) {
            $useMinMax = false;
            if (isset($endDate['min'])) {
                $this->addUsingAlias(LpUmowyStanowiskaPeer::DATADO, $endDate['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($endDate['max'])) {
                $this->addUsingAlias(LpUmowyStanowiskaPeer::DATADO, $endDate['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(LpUmowyStanowiskaPeer::DATADO, $endDate, $comparison);
    }

    /**
     * Filter the query on the Stanowisko column
     *
     * Example usage:
     * <code>
     * $query->filterByPositionId('fooValue');   // WHERE Stanowisko = 'fooValue'
     * $query->filterByPositionId('%fooValue%'); // WHERE Stanowisko LIKE '%fooValue%'
     * </code>
     *
     * @param     string $positionId The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return LpUmowyStanowiskaQuery The current query, for fluid interface
     */
    public function filterByPositionId($positionId = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($positionId)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $positionId)) {
                $positionId = str_replace('*', '%', $positionId);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(LpUmowyStanowiskaPeer::STANOWISKO, $positionId, $comparison);
    }

    /**
     * Filter the query on the LpLogo column
     *
     * Example usage:
     * <code>
     * $query->filterByLogoId('fooValue');   // WHERE LpLogo = 'fooValue'
     * $query->filterByLogoId('%fooValue%'); // WHERE LpLogo LIKE '%fooValue%'
     * </code>
     *
     * @param     string $logoId The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return LpUmowyStanowiskaQuery The current query, for fluid interface
     */
    public function filterByLogoId($logoId = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($logoId)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $logoId)) {
                $logoId = str_replace('*', '%', $logoId);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(LpUmowyStanowiskaPeer::LPLOGO, $logoId, $comparison);
    }

    /**
     * Filter the query by a related LpPositions object
     *
     * @param   LpPositions $positions The related object to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   LpUmowyStanowiskaQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByPositions($positions, $comparison = null)
    {
        if ($positions instanceof LpPositions) {
            return $this
                ->addUsingAlias(LpUmowyStanowiskaPeer::LPLOGO, $positions->getLogoId(), $comparison)
                ->addUsingAlias(LpUmowyStanowiskaPeer::STANOWISKO, $positions->getId(), $comparison);
        } else {
            throw new PropelException('filterByPositions() only accepts arguments of type LpPositions');
        }
    }

    /**
     * Adds a JOIN clause to the query using the Positions relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return LpUmowyStanowiskaQuery The current query, for fluid interface
     */
    public function joinPositions($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('Positions');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'Positions');
        }

        return $this;
    }

    /**
     * Use the Positions relation Positions object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   LpPositionsQuery A secondary query class using the current class as primary query
     */
    public function usePositionsQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    {
        return $this
            ->joinPositions($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'Positions', 'LpPositionsQuery');
    }

    /**
     * Exclude object from result
     *
     * @param   LpUmowyStanowiska $umowyStanowiska Object to remove from the list of results
     *
     * @return LpUmowyStanowiskaQuery The current query, for fluid interface
     */
    public function prune($umowyStanowiska = null)
    {
        if ($umowyStanowiska) {
            $this->addUsingAlias(LpUmowyStanowiskaPeer::LP_UMOWYSTANOWISKAID, $umowyStanowiska->getId(), Criteria::NOT_EQUAL);
        }

        return $this;
    }

}
